<style scoped>
    .app{
        height: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
    }
</style>
<template>
    <div class="app">
        <router-view v-if="isRouterAlive"></router-view>
    </div>
</template>
<script>
    export default {
        name:'app',
        provide(){
            return {
                reload:this.reload
            };
        },
        data() {
            return {
                isRouterAlive : true,
            };
        },
        created() {
            if (this.$route.path !== '/') {
                this.loadMenuData()
            }
        },
        mounted() {

        },
        beforeDestroy() {

        },
        watch: {
            /* eslint-disable */
            '$store.state.login.loginStatus': function(newv, oldv) {
                if (newv && this.$route.path !== '/') {
                    this.loadMenuData()
                }
            }
            /* eslint-disable */
        },
        methods: {
            reload(){
                this.isRouterAlive = false;
                this.$nextTick(()=>{
                    this.isRouterAlive = true;
                });
            },
            /* eslint-disable */
            loadMenuData() {
                // 获取用户菜单，此项目写死，默认由接口控制
                let vroutes = []
                let menus = [{
                    title: '系统管理',
                    code: 'manage',
                    children: [{
                        title: '人员管理',
                        code: 'manage-auth',
                        url: '/main/manage/auth'
                    }]
                },{
                    title: '业务管理',
                    code: 'business',
                    children: [{
                        title: '算法管理',
                        code: 'business-algorithm',
                        url: '/main/business/algorithm'
                    }]
                }]
                this.$store.dispatch('menu/refresh', menus)          
            }
            /* eslint-disable */
        }
    };
</script>
